
#ifndef __KHAN_CLI_VTY_HPP__
#define __KHAN_CLI_VTY_HPP__

#include "khan.hpp"

#define VTY_NEWLINE "\r\n"

class vty;
typedef boost::shared_ptr<vty>  vty_ptr;

typedef int (*ExecuteFunc)(vty_ptr, const std::string&, string_vector&);
typedef boost::function<int(vty_ptr, const std::string&, string_vector&)> ExcuteHandle;
typedef boost::function<int(vty_ptr, const std::string)> DialogHandle;

class vty
{
private:

public:
    virtual ~vty() {};

    virtual int id() = 0;

    virtual bool is_auth_mode() = 0;
    virtual bool is_auth_mode(const std::string& mode) = 0;

    virtual bool check_passwd(const std::string passwd) = 0;

    virtual bool change_mode(const std::string& mode) = 0;
    virtual const std::string current_mode()  = 0;

    virtual int output(const char c) = 0;
    virtual int output(const std::string& string) = 0 ;
    virtual int output(const char* fmt, ...) = 0;

    virtual bool is_dialog() = 0;
    virtual int stop_dialog() = 0;
    virtual int start_dialog(DialogHandle hdnl) = 0;

    /* may be remove */
    virtual const std::string prompt() = 0;
    virtual const std::string get_banner() = 0;
    virtual void set_banner(const std::string& banner) = 0; 
    virtual void excute_pty(const string_vector& cmdvec) = 0;
    virtual void set_func_flag(bool flag) { };
    virtual bool get_func_flag() { return true; };

#if 0
    /* FIXME: remove me */
    virtual bool is_pty() = 0;
    virtual tcp_socket& socket()  = 0; /* FIXME: remove socket() */
#endif
    virtual void stop() = 0;    
    virtual bool is_stop() = 0; /* is_stop() -> opened() */
    virtual void excute_command(const std::string commandline) = 0;
    virtual void describe_command(const std::string commandline) = 0;
    virtual void complete_command(const std::string commandline) = 0;
/*
    virtual bool add_mode(const std::string name, const std::string prompt, bool is_auth = false) = 0;
    virtual bool add_command(const std::string mode, const std::string cmd, const std::string help, const runnable* run=NULL) =0 ;
    */
};

#endif 
